// 构造函数的返回值- 没有返回值
function Otaku (name, age) {
  this.name = name
  this.age = age
}
Otaku.prototype.sayName = function () {
  return this.name + ' i am an attr in function'
}

var ot = new Otaku('lee', 28)
console.log(ot.name)
console.log(ot.age)
console.log(ot.sayName())


console.log('-----------------------------')


// 构造函数的返回值 - 返回值为一个对象-此时实例中智能访问返回对象中的属性
function Otaku_ (name, age) {
  this.name = name
  this.age = age
  return {
    name,
    age
  }
}
Otaku_.prototype.sayName = function () {
  return this.name + ' i am an attr in function'
}

var obj2 = new Otaku_('lee', 28)
console.log(obj2.name)
console.log(obj2.age)
console.log(obj2.sayName) // undefined




// 构造函数的返回值 - 返回一个基本类型 - 相当于没有做处理，会忽略这个返回值
function Otaku$ (name, age) {
  this.name = name
  this.age = age
  return 1
}
Otaku$.prototype.sayName = function () {
  return this.name + ' i am an attr in function'
}
console.log('-----------------------------')
var ot2 = new Otaku$('leee', 283)
console.log(ot2.name)
console.log(ot2.age)
console.log(ot2.sayName())

